using AndyPike.Presentations.IntroToTDD.Interfaces;
using NUnit.Framework;
using Rhino.Mocks;

namespace AndyPike.Presentations.IntroToTDD.Tests
{
    [TestFixture]
    public class When_logging_to_the_console
    {
        private MockRepository mockery;
        private IConsole console;

        [SetUp]
        public void SetUp()
        {
            mockery = new MockRepository();
            console = mockery.DynamicMock<IConsole>();
        }

        [Test]
        public void Should_leverage_a_console_adapter()
        {
            const string message = "This is a message.";
            var logger = new ConsoleLogger { Console = console };

            using (mockery.Record())
            {
                Expect.Call(() => console.WriteLine("INFO: " + message));
            }

            using (mockery.Playback())
            {
                logger.Info(message);
            }
        }
    }
}